home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_bas / t2win_32.zip / _COMPRES.FRM < prev    next >
Text File  |  1996-05-14  |  8KB  |  276 lines

  1. VERSION 4.00
  2. Begin VB.Form frmCompress 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Compress - Expand"
  5.    ClientHeight    =   4845
  6.    ClientLeft      =   1890
  7.    ClientTop       =   3270
  8.    ClientWidth     =   7485
  9.    Height          =   5250
  10.    Left            =   1830
  11.    MaxButton       =   0   'False
  12.    MDIChild        =   -1  'True
  13.    ScaleHeight     =   4845
  14.    ScaleWidth      =   7485
  15.    ShowInTaskbar   =   0   'False
  16.    Top             =   2925
  17.    Width           =   7605
  18.    Begin VB.TextBox txt_Result 
  19.       BackColor       =   &H00C0C0C0&
  20.       BorderStyle     =   0  'None
  21.       Height          =   4110
  22.       Left            =   105
  23.       Locked          =   -1  'True
  24.       MultiLine       =   -1  'True
  25.       ScrollBars      =   2  'Vertical
  26.       TabIndex        =   0
  27.       Top             =   630
  28.       Width           =   7260
  29.    End
  30.    Begin Threed.SSPanel SSPanel1 
  31.       Align           =   1  'Align Top
  32.       Height          =   480
  33.       Left            =   0
  34.       TabIndex        =   1
  35.       Top             =   0
  36.       Width           =   7485
  37.       _Version        =   65536
  38.       _ExtentX        =   13203
  39.       _ExtentY        =   847
  40.       _StockProps     =   15
  41.       ForeColor       =   -2147483640
  42.       BackColor       =   12632256
  43.       Begin VB.ComboBox cmb_Function 
  44.          Height          =   315
  45.          Left            =   1365
  46.          TabIndex        =   2
  47.          Top             =   90
  48.          Width           =   4785
  49.       End
  50.       Begin Threed.SSCommand cmdNP 
  51.          Height          =   300
  52.          Index           =   1
  53.          Left            =   7140
  54.          TabIndex        =   6
  55.          Top             =   90
  56.          Width           =   255
  57.          _Version        =   65536
  58.          _ExtentX        =   450
  59.          _ExtentY        =   529
  60.          _StockProps     =   78
  61.          Caption         =   ">"
  62.          BevelWidth      =   1
  63.          Font3D          =   3
  64.          RoundedCorners  =   0   'False
  65.          Outline         =   0   'False
  66.       End
  67.       Begin Threed.SSCommand cmdNP 
  68.          Height          =   300
  69.          Index           =   0
  70.          Left            =   6300
  71.          TabIndex        =   5
  72.          Top             =   90
  73.          Width           =   255
  74.          _Version        =   65536
  75.          _ExtentX        =   450
  76.          _ExtentY        =   529
  77.          _StockProps     =   78
  78.          Caption         =   "<"
  79.          BevelWidth      =   1
  80.          Font3D          =   3
  81.          RoundedCorners  =   0   'False
  82.          Outline         =   0   'False
  83.       End
  84.       Begin VB.Label Label2 
  85.          Caption         =   "&Select a function"
  86.          Height          =   255
  87.          Left            =   90
  88.          TabIndex        =   4
  89.          Top             =   120
  90.          Width           =   1275
  91.       End
  92.       Begin Threed.SSCommand SSCommand1 
  93.          Default         =   -1  'True
  94.          Height          =   300
  95.          Left            =   6615
  96.          TabIndex        =   3
  97.          Top             =   90
  98.          Width           =   465
  99.          _Version        =   65536
  100.          _ExtentX        =   820
  101.          _ExtentY        =   529
  102.          _StockProps     =   78
  103.          Caption         =   "&Go"
  104.          BevelWidth      =   1
  105.          RoundedCorners  =   0   'False
  106.          Outline         =   0   'False
  107.       End
  108.    End
  109. End
  110. Attribute VB_Name = "frmCompress"
  111. Attribute VB_Creatable = False
  112. Attribute VB_Exposed = False
  113. Option Explicit
  114. Option Base 1
  115.  
  116. Private Const Iteration = 10
  117.  
  118. Dim IsLoaded         As Integer
  119.  
  120. Dim TimerStartOk     As Integer
  121. Dim TimerCloseOk     As Integer
  122.  
  123. Dim TimerHandle      As Integer
  124. Dim TimerValue       As Long
  125.  
  126. Private Sub cmb_Function_Click()
  127.    
  128.    If (IsLoaded = False) Then Exit Sub
  129.    
  130.    Call cDisableFI(mdiT2W.Picture1)
  131.    
  132.    txt_Result = ""
  133.    
  134.    DoEvents
  135.    
  136.    Select Case cmb_Function.ListIndex
  137.       Case 0
  138.          Call TestFileCompress
  139.       Case 1
  140.          Call TestStringCompress
  141.    End Select
  142.  
  143.    DoEvents
  144.    Call cEnableFI(mdiT2W.Picture1)
  145.    
  146. End Sub
  147.  
  148.  
  149. Private Sub cmdNP_Click(Index As Integer)
  150.  
  151.    Call sub_NextPrev(cmb_Function, Index)
  152.  
  153. End Sub
  154.  
  155. Private Sub Form_Activate()
  156.  
  157.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  158.  
  159. End Sub
  160.  
  161. Private Sub Form_Load()
  162.  
  163.    IsLoaded = False
  164.    
  165.    Show
  166.  
  167.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_compres.t2w")
  168.    
  169.    IsLoaded = True
  170.    
  171. End Sub
  172.  
  173. Private Sub SSCommand1_Click()
  174.    
  175.    Call cmb_Function_Click
  176.    
  177. End Sub
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185. Private Sub TestFileCompress()
  186.  
  187.    Dim lngResult        As Long
  188.    Dim strResult        As String
  189.    Dim strDisplay       As String
  190.    
  191.    Dim i                As Integer
  192.    
  193.    Dim File1            As String
  194.    Dim File2            As String
  195.    Dim File3            As String
  196.    
  197.    strResult = ""
  198.    strDisplay = ""
  199.    
  200.    File1 = T2WFileTest
  201.    File2 = "autoexec.compressed"
  202.    File3 = "autoexec.expanded"
  203.    
  204.    strDisplay = strDisplay & "File Compress '" & File1 & "' to '" & File2 & "' is " & cFileCompress(File1, File2) & vbCrLf
  205.    strDisplay = strDisplay & "File Expand '" & File2 & "' to '" & File3 & "' is " & cFileExpand(File2, File3) & vbCrLf
  206.    strDisplay = strDisplay & "Compare File contents (not sensitive) '" & File1 & "' with '" & File3 & "' is " & IIf(cCmpFileContents(File1, File3, False) = -1, "same", "not same") & vbCrLf & vbCrLf
  207.  
  208.    txt_Result = strDisplay
  209.  
  210.    'time the function
  211.  
  212.    TimerHandle = cTimerOpen()
  213.    TimerStartOk = cTimerStart(TimerHandle)
  214.    
  215.    For i = 1 To Iteration
  216.       lngResult = cFileCompress(File1, File2)
  217.    Next i
  218.    
  219.    lngResult = cFileExpand(File2, File3)
  220.    
  221.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  222.    
  223.    TimerCloseOk = cTimerClose(TimerHandle)
  224.  
  225. End Sub
  226.  
  227. Public Sub TestStringCompress()
  228.  
  229.    Dim lngResult        As Long
  230.    Dim strResult        As String
  231.    Dim strDisplay       As String
  232.    
  233.    Dim i                As Integer
  234.    
  235.    Dim Str1             As String
  236.    Dim Str2             As String
  237.    Dim Str3             As String
  238.    
  239.    strResult = ""
  240.    strDisplay = ""
  241.    
  242.    Str1 = "T2WIN-32, t2win-32, T2WIN-32, t2win-32, T2WIN-32, t2win-32"
  243.    Str2 = cStringCompress(Str1)
  244.    Str3 = cStringExpand(Str2)
  245.    
  246.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  247.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  248.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  249.  
  250.    Str1 = String$(30, "a") + String$(6, "b") + String$(5, "c") + String$(4, "d")
  251.    Str2 = cStringCompress(Str1)
  252.    Str3 = cStringExpand(Str2)
  253.    
  254.    strDisplay = strDisplay & "String Compress '" & Str1 & "' is " & Format$(Len(Str1)) & " to " & Format$(Len(Str2)) & " bytes." & vbCrLf
  255.    strDisplay = strDisplay & "String Expand is '" & Str3 & "'" & vbCrLf
  256.    strDisplay = strDisplay & "Compare string contents (not sensitive) is " & IIf(LCase$(Str1) = LCase$(Str3), "same", "not same") & vbCrLf & vbCrLf
  257.  
  258.    txt_Result = strDisplay
  259.  
  260.    'time the function
  261.  
  262.    TimerHandle = cTimerOpen()
  263.    TimerStartOk = cTimerStart(TimerHandle)
  264.    
  265.    For i = 1 To Iteration
  266.       Str2 = cStringCompress(Str1)
  267.    Next i
  268.    
  269.    Str3 = cStringExpand(Str2)
  270.    
  271.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  272.    
  273.    TimerCloseOk = cTimerClose(TimerHandle)
  274.  
  275. End Sub
  276.